home *** CD-ROM | disk | FTP | other *** search
- #include "String.h"
- #include "ctype.h"
-
- RJS_String &RJS_String::trim(Side t)
- {
- char *p,*q;
- int len,i;
-
- q=p=sd.data;
-
- if (isspace(*q) && (t & Left)) {
- len=0; i=0;
- while (i<length() && isspace(*q)) q++,i++; // skip white space
- while (i<length()) { // copy non-white space
- *p++ = *q++;
- i++;
- len++;
- }
- } else len=length();
-
- if (t & Right) while(len && isspace(sd.data[len-1])) len--;
-
- if (len!=length()) trunc(len);
-
- return *this;
- }
-
- RJS_String trim(const char *s,Side t)
- {
- RJS_String temp(s);
-
- return temp.trim(t);
- }
-
- RJS_String trim(const RJS_String &s,Side t)
- {
- RJS_String temp(s);
-
- return temp.trim(t);
- }
-
-